﻿@* #region - Legal -
Copyright © 2011, Tateeda Media Network
All rights reserved. http://tateeda.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions
of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
- Neither the name of the Tateeda Media Network, nor the
names of its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED
BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion - Legal *@
@using Tateeda.ClinicalStudy.Base.Modules.Models.Medication;
@using Tateeda.ClinicalStudy.Base.Modules.Lookups;
@model ICollection<SubjectDrugModel>
@{
    int DEFAULT_PSYCOTROPIC_CATEGORY = 1;
    int DEFAULT_NON_PSYCOTROPIC_CATEGORY = 2;
}
<h3>
    <a href="#">Psychotropic Prescription Drugs</a>
</h3>
<div id="PsychoDrugsRoot">
    <div class="clearfix">
        <!-- DO not make it visible and do not delete -->
        <div style="visibility: hidden">
            <select id="prescriptionCategory" class="dropDownGlobal">
                <option>--Select--</option>
            </select>
        </div>
        <table class="noBorders">
            <tr>
                <th>
                    <!-- This is the Class, we are doing hack here to use same class for all prescription drugs -->
                    Category<span class="requiredField">*</span>
                </th>
                <th>
                    Name<span class="requiredField">*</span>
                </th>
                <th>
                    Start Date<span class="requiredField">*</span>
                </th>
                <th>
                    End Date
                </th>
                <th>
                    Daily Dose<span class="requiredField">*</span>
                </th>
                <th>
                    Units<span class="requiredField">*</span>
                </th>
                <th>
                    Frequency<span class="requiredField">*</span>
                </th>
            </tr>
            <tr>
                <td>
                    <select id="prescriptionClass" class="dropDownGlobal required">
                        <option>--Select--</option>
                    </select>
                </td>
                <td>
                    <select id="prescriptionName" class="dropDownGlobal required">
                        <option>--Select--</option>
                    </select>
                </td>
                <td>
                    <input type="text" id="prescriptionStart" class="textBoxForDatesGlobal required" />
                </td>
                <td>
                    <input type="text" id="prescriptionEnd" class="textBoxForDatesGlobal" />
                </td>
                <td>
                    <input type="text" id="prescriptionDose" class="textBoxShort20Global required" />
                </td>
                <td>
                    @Html.DropDownList("prescriptionDrugUnit", Medication.DrugUnitsList, new { @class = "dropDownGlobalShort required" })
                </td>
                <td>
                    @Html.DropDownList("psycoFrequency", Medication.FrequencyList, new { @class = "dropDownGlobalMedium required" })
                </td>
            </tr>
        </table>
        <div>
            <span class="Title">Comments</span>
            <input type="text" id="prescriptionComment" class="dynamicTextLong" style="width: 90%;" />
            <span>
                <input type="button" class="buttonGlobalShort add" value="Add" onclick="AddPrescription();" />
            </span>
        </div>
    </div>
    <br />
    <br />
    <div id="currentPsycoSummary">
        <table class="noBorders">
            @foreach (var med in Model.Where(m => m.IsBeforeStudy == false)) {
                <tr>
                    @if (med.IsSychotropic) {

                        <td>
                            <table class="noBorders">
                                <tr>
                                    <th>
                                        Drug
                                    </th>
                                    <th>
                                        Dose
                                    </th>
                                    <th>
                                        Type
                                    </th>
                                    <th>
                                        Start
                                    </th>
                                    <th>
                                        Status
                                    </th>
                                    <th>
                                        End
                                    </th>
                                    <th>
                                        Comment
                                    </th>
                                </tr>
                                <tr>
                                    @Html.Raw(string.Format("<td width=40%><b><i>{0}</i></b></td><td><b>{1}</b></td><td>{2}</td><td>{3:d}</td><td>{4}</td><td><b>{5:d}</b></td><td>{6}</td>",
                                med.Name, med.Dosage, med.DosageType, med.StartDate, med.IsCurrent == true ? "Current" : "Stopped", med.EndDate, med.Comments))
                                </tr>
                            </table>
                        </td>
                        <td>
                            <input type='button' value='Delete' class='buttonGlobalShort deleteSmall' onclick="DeleteSubjectsDrug('@med.SubjectDrugId');" />
                        </td>
                        <td>
                            <input readonly='readonly' style='width:40px;' class='historyIcon' onclick="GetMedicationChangeHistory('@med.SubjectDrugId');" />
                        </td>
                        <td>
                            <span id='history_@(med.SubjectDrugId)' class='history'  onclick="HideHistory('@med.SubjectDrugId');">
                            </span>
                        </td>
                        <td class='nw'>
                            @if (med.IsCurrent) {
                                <table class="noBorders">
                                    <tr>
                                        <td>
                                            <input type='button' value='Stop' class='buttonGlobalShort stopSmall' onclick="StopDrug('@med.SubjectDrugId');" />
                                        </td>
                                        <td>
                                            <input type='button' value='Change' class='buttonGlobalShort editSmall' onclick="ChangeDoseDrug('@med.SubjectDrugId');" />
                                        </td>
                                        <td class='nw'>
                                            <span class='currentMedstopDateSpan' id='currentMedstopDateSpan_@(med.SubjectDrugId)'>
                                                <span class='Title'>Date:</span>
                                                <input type='text' id='currentMedstopDate_@(med.SubjectDrugId)' class='textBoxForDatesGlobal' value='@(string.Format("{0:d}", DateTime.Now.ToShortDateString()))' />
                                                <input type='button' value='Update' class='buttonGlobalShort add' onclick="UpdateStopDrug('@med.SubjectDrugId');" />
                                            </span>
                                        </td>
                                        <td class='nw'>
                                            <span class='currentMedChangeDoseSpan' id='currentMedChangeDoseSpan_@(med.SubjectDrugId)'>
                                                <span class='Title'>Dose:</span>
                                                <input type='text' id='currentMedChangeDose_@(med.SubjectDrugId)' class='textBoxShort20Global' value='@med.Dosage' />
                                                <span class='Title'>Date:</span>
                                                <input type='text' id='currentMedChangeDate_@(med.SubjectDrugId)' class='textBoxForDatesGlobal' value='@(string.Format("{0:d}", DateTime.Now.ToShortDateString()))' />
                                                <input type='button' value='Update' class='buttonGlobalShort add' onclick="UpdateChangeDoseDrug('@med.SubjectDrugId ');" />
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            }
                        </td>
                    }
                </tr>
            }
        </table>
    </div>
</div>
<h3>
    <a href="#">Non Psychotropic Drugs and Over Counter Medication</a>
</h3>
<div id="NonPsychoDrugsRoot">
    <div class="clearfix">
        <table class="noBorders">
            <tr class="noBorders">
                <th>
                    Name<span class="requiredField">*</span>
                </th>
                <th>
                    Start Date<span class="requiredField">*</span>
                </th>
                <th>
                    End Date
                </th>
                <th style="white-space: nowrap;">
                    Daily Dose<span class="requiredField">*</span>
                </th>
                <th>
                    Units<span class="requiredField">*</span>
                </th>
                <th>
                    Frequency<span class="requiredField">*</span>
                </th>
            </tr>
            <tr class="noBorders">
                <td style="width: 30%">
                    <input type="hidden" id="editableComboboxInputText" class="required" />
                    <select id="editableComboboxnonPsychoDrugName">
                    </select>
                </td>
                <td>
                    <input type="text" id="nonPsychoStartDate" class="textBoxForDatesGlobal required" />
                </td>
                <td>
                    <input type="text" id="nonPsychoEndDate" class="textBoxForDatesGlobal" />
                </td>
                <td>
                    <input type="text" id="nonPsychoDose" class="textBoxShort20Global required" />
                </td>
                <td>
                    @Html.DropDownList("nonPsychoDrugUnit", Medication.DrugUnitsList, new { @class = "dropDownGlobalShort required" })
                </td>
                <td>
                    @Html.DropDownList("nonPsycoFrequency", Medication.FrequencyList, new { @class = "dropDownGlobalMedium required" })
                </td>
            </tr>
        </table>
        <div>
            <span class="Title">Comments</span>
            <input type="text" id="nonPsychoComment" class="dynamicTextLong" style="width: 640px;" />
            <span>
                <input type="button" class="buttonGlobalShort add" value="Add" onclick="AddNonPsychoDrug();" />
            </span>
        </div>
    </div>
    <br />
    <br />
    <div id="currentNonPsycoSummary">
        <table>
            @foreach (var medNP in Model.Where(m => m.IsBeforeStudy == false)) {
                <tr>
                    @if (!medNP.IsSychotropic) {

                        <td>
                            <table class="noBorders">
                                <tr class="noBorders">
                                    <th>
                                        Drug
                                    </th>
                                    <th>
                                        Dose
                                    </th>
                                    <th>
                                        Type
                                    </th>
                                    <th>
                                        Start
                                    </th>
                                    <th>
                                        Status
                                    </th>
                                    <th>
                                        End
                                    </th>
                                    <th>
                                        Comment
                                    </th>
                                </tr>
                                <tr>
                                    @Html.Raw(string.Format("<td><b><i>{0}</i></b></td><td><b>{1}</b></td><td>{2}</td><td>{3:d}</td><td>{4}</td><td><b>{5:d}</b></td><td>{6}</td>",
                                medNP.Name, medNP.Dosage, medNP.DosageType, medNP.StartDate, medNP.IsCurrent == true ? "Current" : "Stopped", medNP.EndDate, medNP.Comments))
                                </tr>
                            </table>
                        </td>
                        <td>
                            <input type='button' value='Delete' class='buttonGlobalShort deleteSmall' onclick="DeleteSubjectsDrug('@medNP.SubjectDrugId');" />
                        </td>
                        <td>
                            <input readonly='readonly' style='width:40px;' class='historyIcon' onclick="GetMedicationChangeHistory('@medNP.SubjectDrugId');" />
                        </td>
                        <td>
                            <span id='history_@(medNP.SubjectDrugId)' class='history' onclick="HideHistory('@medNP.SubjectDrugId');">
                            </span>
                        </td>

                        <td>
                            @if (medNP.IsCurrent) {
                                <table class="noBorders">
                                    <tr class="noBorders">
                                        <td>
                                            <input type='button' value='Stop' class='buttonGlobalShort stopSmall' onclick="StopDrug('@medNP.SubjectDrugId');" />
                                        </td>
                                        <td>
                                            <input type='button' value='Change' class='buttonGlobalShort editSmall' onclick="ChangeDoseDrug('@medNP.SubjectDrugId');" />
                                        </td>
                                        <td>
                                            <span class='currentMedstopDateSpan' id='currentMedstopDateSpan_@(medNP.SubjectDrugId)'>
                                                <span class='Title'>Date:</span>
                                                <input type='text' id='currentMedstopDate_@(medNP.SubjectDrugId)' class='textBoxForDatesGlobal' value='@(string.Format("{0:d}", DateTime.Now.ToShortDateString()))' />
                                                <input type='button' value='Update' class='buttonGlobalShort add' onclick="UpdateStopDrug('@medNP.SubjectDrugId');" />
                                            </span>
                                        </td>
                                        <td>
                                            <span class='currentMedChangeDoseSpan' id='currentMedChangeDoseSpan_@(medNP.SubjectDrugId)'>
                                                <span class='Title'>Dose:</span>
                                                <input type='text' id='currentMedChangeDose_@(medNP.SubjectDrugId)' class='TextBoxShort20Global' value='@medNP.Dosage' />
                                                <span class='Title'>Date:</span>
                                                <input type='text' id='currentMedChangeDate_@(medNP.SubjectDrugId)' class='textBoxForDatesGlobal' value='@(string.Format("{0:d}", DateTime.Now.ToShortDateString()))' />
                                                <input type='button' value='Update' class='buttonGlobalShort add' onclick="UpdateChangeDoseDrug('@medNP.SubjectDrugId');" />
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            }
                        </td>
                    }
                </tr>
            }
        </table>
    </div>
</div>